package org.jet.emall.prod.transfer;

import org.jet.emall.prod.dto.BrandDTO;
import org.jet.emall.prod.dto.BrandDetailsDTO;
import org.jet.emall.prod.dto.NewBrandDTO;
import org.jet.emall.prod.dto.UpdateBrandDTO;
import org.jet.emall.prod.po.ProdBrand;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-16 13:56
 */
@Mapper
public interface BrandDtoTransfer {

    BrandDtoTransfer INSTANCE = Mappers.getMapper(BrandDtoTransfer.class);

    /**
     *  将品牌PO列表转DTO列表
     * @param records
     * @return
     */
    List<BrandDTO> toDtoList(List<ProdBrand> records);

    /**
     *  将新建品牌DTO转PO
     * @param dto
     * @return
     */
    @Mappings({
            @Mapping(target = "id",ignore = true),
            @Mapping(target = "deleted",ignore = true),
            @Mapping(target = "modifiedTime",ignore = true)
    })
    ProdBrand toPo(NewBrandDTO dto);


    @Mappings({
            @Mapping(target = "deleted",ignore = true),
            @Mapping(target = "modifiedTime",ignore = true)
    })
    ProdBrand toPo(UpdateBrandDTO dto);

    /** 将品牌PO转DTO详情，但信息不全
     *
     * @param prodBrand
     * @return
     */
    @Mappings({

    })
    BrandDetailsDTO toDto(ProdBrand prodBrand);
}
